Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DuckDB tests #1970

Merged
merged 3 commits into from
Oct 11, 2023
Merged

Add DuckDB tests #1970

merged 3 commits into from
Oct 11, 2023

Conversation

Giorgi
Copy link
Contributor

@Giorgi Giorgi commented Oct 3, 2023

Test for #1952

The NuGet package includes native libraries too.

Copy link
Member

@mgravell mgravell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine - I will need to try it locally - will try to do tomorrow

@mgravell
Copy link
Member

I'm happy to merge as-is, but FYI: this doesn't actually work for netfx - I see that there's a netstandard2.0 package in the nuget, but: it doesn't seem to work; it doesn't work in the tests here, and doesn't work in standalone packages either; example:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net472</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <LangVersion>12</LangVersion>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="DuckDB.NET.Data.Full" Version="0.9.0.3"/>
    </ItemGroup>
</Project>

with:

using DuckDB.NET.Data;

using var conn = new DuckDBConnection("Data Source=:memory:");
conn.Open();

gives:

Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'duckdb': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at DuckDB.NET.NativeMethods.Startup.DuckDBOpen(String path, DuckDBDatabase& database, DuckDBConfig config, IntPtr& error)
   at DuckDB.NET.Data.Internal.ConnectionManager.GetConnectionReference(DuckDBConnectionString connectionString)
   at DuckDB.NET.Data.DuckDBConnection.Open()
   at Program.<Main>$(String[] args) in C:\Code\ConsoleApp7\ConsoleApp7\Program.cs:line 4

The packaging might not be right. I haven't looked to see what you're packaging and how - it doesn't look like there are native binaries in the nupkg itself, so I'm guessing that they are embedded resources in the dll? More of a topic for DuckDB, but you might prefer to embed them in the nupkg rather than the dll; I also haven't checked to see how the unmanaged dll works re cross-platform (normally I'd expect to see a bunch of platform-specific native dlls in the nupkg, for this purpose)

(let me know if you need any help with any of this)

@mgravell
Copy link
Member

see also:

image

where the failure is:

DuckDB is unavailable: Unable to load DLL 'duckdb': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

@mgravell mgravell merged commit 2837480 into DapperLib:main Oct 11, 2023
2 checks passed
@Giorgi
Copy link
Contributor Author

Giorgi commented Oct 11, 2023

It doesn't work for netfx but works for net core. The native libraries are under runtime folder but netfx doesn't know how to load them: https://stackoverflow.com/questions/56154884/nuget-package-not-copying-native-dlls-on-build

@Giorgi
Copy link
Contributor Author

Giorgi commented Oct 11, 2023

The native libraries are in another package that the top level depends on DuckDB.NET.Bindings.Full

image

@mgravell
Copy link
Member

logged here: Giorgi/DuckDB.NET#151 - I guess the key bit is "it didn't work"

@mgravell
Copy link
Member

@Giorgi ah, it is 32-bit vs 64-bit; see 151

@mgravell
Copy link
Member

(I still can't get the tests to run in netfx, but my standalone console works 🤷)

@mgravell
Copy link
Member

It doesn't work for netfx but works for net core. The native libraries are under runtime folder but netfx doesn't know how to load them: https://stackoverflow.com/questions/56154884/nuget-package-not-copying-native-dlls-on-build

I'm using SDK-style project, so this should work; it now works for the standalone console, if I explicitly use x64 rather than the implicit anycpu which is picking up x86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants